package com.kehan.aidl_server.service;

import android.app.Service;
import android.content.Intent;
import android.os.IBinder;
import android.os.Process;
import android.os.RemoteException;
import android.util.Log;

import com.kehan.aidl_server.IRemoteAidlServiceInterface;
import com.kehan.aidl_server.entity.SensorConfig;

public class MyService extends Service {

    private final String TAG = "MyService";

    private RemoteBinder binder;

    public MyService() {
    }


    private class RemoteBinder extends IRemoteAidlServiceInterface.Stub {

        @Override
        public void basicTypes(int anInt, long aLong, boolean aBoolean, float aFloat, double aDouble, String aString) throws RemoteException {
            Log.d(TAG, "basicTypes anInt:" + anInt + ";aLong:" + aLong + ";aBoolean:" + aBoolean + ";aFloat:" + aFloat + ";aDouble:" + aDouble + ";aString:" + aString);
        }

        @Override
        public int getPid() throws RemoteException {
            return Process.myPid();
        }

        @Override
        public void setSensor(SensorConfig sensorConfig) throws RemoteException {
            Log.d(TAG, "sensorConfig 信息"+sensorConfig.toString());
        }
    }

    @Override
    public void onCreate() {
        super.onCreate();

        binder = new RemoteBinder();
    }

    @Override
    public IBinder onBind(Intent intent) {
        Log.d(TAG, "onBind");
        return binder;
    }


    @Override
    public int onStartCommand(Intent intent, int flags, int startId) {
        Log.d(TAG, "onStartCommand");
        return super.onStartCommand(intent, flags, startId);

    }
}